<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">


    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>

        <h:panelGroup rendered="true" >
            <h:form>
                <p:panel id="panelPrint" styleClass="noBorder summeryBorder" header="Investigation Count With Machine(By Item)">
                    <f:facet name="header" >
                        <p:outputLabel value="Investigation Count With Machine(By Item)" styleClass="noPrintButton"/>
                        <h:panelGrid columns="2" styleClass="noPrintButton">
                            <h:outputLabel value="From Date"/>
                            <p:calendar id="frmDate" value="#{investigationMonthSummeryOwnController.fromDate}" pattern="dd MMMM yyyy HH:mm:ss" >
                            </p:calendar>
                            <h:outputLabel value="To Date"/>
                            <p:calendar id="toDate" value="#{investigationMonthSummeryOwnController.toDate}" pattern="dd MMMM yyyy HH:mm:ss" >
                            </p:calendar>
                            <h:outputLabel  value="Institution"  ></h:outputLabel>
                            <p:autoComplete  value="#{investigationMonthSummeryOwnController.institution}" 
                                             completeMethod="#{institutionController.completeIns}" 
                                             var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                            </p:autoComplete>
                        </h:panelGrid>
                        <h:panelGrid columns="5" styleClass="noPrintButton">
                            <p:spacer width="70" height="1"/>
                            <p:commandButton ajax="false"  value="Refresh" 
                                             action="#{investigationMonthSummeryOwnController.createLabServiceWithCountByMachine()}"
                                             styleClass="noPrintButton" style="float: right;" />



                            <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" style="float:right;">
                                <p:printer target="panelPrint" />
                            </p:commandButton>

                            <p:commandButton value="Excel" ajax="false" styleClass="noPrintButton" style="float: right;" >
                                <pe:exporter type="xlsx" target="tbl" fileName="Investigation Count With Machine(By Item) From #{investigationMonthSummeryOwnController.fromDate} To #{investigationMonthSummeryOwnController.toDate}"
                                             facetBackground="#008000" facetFontSize="15" 
                                             facetFontColor="#FFFFFF" facetFontStyle="BOLD" cellFontColor="#0000FF" cellFontSize="12"  cellFontStyle="NORMAL"  
                                             fontName="Courier New"  />
                            </p:commandButton>      



                        </h:panelGrid>
                    </f:facet>
                    <p:dataTable id="tbl" value="#{investigationMonthSummeryOwnController.investigationCountWithMachines}" var="c" >

                        <f:facet name="header">
                            <h:outputLabel value="Investigation Month End Summary"/>
                            <h:outputLabel value="#{investigationMonthSummeryOwnController.institution.name}" style="white-space: pre-line"/>
                            <h:outputLabel value="From : " style="white-space: pre-line"/>
                                <h:outputLabel value="#{investigationMonthSummeryOwnController.fromDate}">
                                    <f:convertDateTime pattern="dd MMMM yyyy hh:mm:ss a" />
                                </h:outputLabel>
                                <h:outputLabel value=" &emsp;To : "/>
                                <h:outputLabel value="#{investigationMonthSummeryOwnController.toDate}">
                                    <f:convertDateTime pattern="dd MMMM yyyy hh:mm:ss a" />
                                </h:outputLabel>
                        </f:facet>

                        <p:column headerText="Machine Name" >
                            <h:outputLabel value="#{c.machine.name}"  />
                        </p:column>
                        <p:column headerText="Count" style="text-align:right" >
                            <h:outputLabel value="#{c.count}" />
                        </p:column>
                        <p:columnGroup type="footer">  
                            <p:row>                              
                                <p:column footerText="Total" colspan="1"/>
                                <p:column footerText="#{investigationMonthSummeryOwnController.countTotal}"  style="text-align:right">
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{investigationMonthSummeryOwnController.totalCount}">
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>                             
                            </p:row>  
                        </p:columnGroup>
                <f:facet name="footer" >
                    <h:outputLabel value="Printed By : #{sessionController.loggedUser.webUserPerson.name}" style="float: right"/>
                </f:facet>
                    </p:dataTable>




                </p:panel>        
            </h:form>
        </h:panelGroup>
    </ui:define>

</ui:composition>
